package com.hliushi.demo.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;


/**
 * CstLinkman
 *
 * @author auto generated
 * @date 2021-07-17 16:26:31
 */
@Data
@Entity
@ToString(exclude = {"customer"})
@EqualsAndHashCode(exclude = {"customer"})
@Table(name = "cst_linkman")
@ApiModel(value = "CstLinkman")
public class CstLinkman implements Serializable {

    private static final long serialVersionUID = 4666602743725199342L;
    /**
     * 联系人编号(主键)
     * nullable : false
     * default  : null
     */
    @Id
    @ApiModelProperty(value = "联系人编号(主键)")
    @Column(name = "lkm_id", nullable = true, length = 32)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long lkmId;

    /**
     * 联系人姓名
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "联系人姓名")
    @Column(name = "lkm_name", nullable = true, length = 16)
    private String lkmName;

    /**
     * 联系人性别
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "联系人性别")
    @Column(name = "lkm_gender", nullable = true, length = 1)
    private String lkmGender;

    /**
     * 联系人办公电话
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "联系人办公电话")
    @Column(name = "lkm_phone", nullable = true, length = 16)
    private String lkmPhone;

    /**
     * 联系人手机
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "联系人手机")
    @Column(name = "lkm_mobile", nullable = true, length = 16)
    private String lkmMobile;

    /**
     * 联系人邮箱
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "联系人邮箱")
    @Column(name = "lkm_email", nullable = true, length = 64)
    private String lkmEmail;

    /**
     * 联系人职位
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "联系人职位")
    @Column(name = "lkm_position", nullable = true, length = 16)
    private String lkmPosition;

    /**
     * 联系人备注
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "联系人备注")
    @Column(name = "lkm_memo", nullable = true, length = 512)
    private String lkmMemo;

    /**
     * 客户id(外键)
     * nullable : false
     * default  : null
     */
    @ApiModelProperty(value = "客户id(外键)")
    @Column(name = "lkm_cust_id", nullable = true, length = 32)
    private Long lkmCustId;


    /**
     * 配置联系人到客户的多对一的关系
     * .    使用注解的形式配置多对一关系
     * .        1.配置表关系
     * .            @ManyToOne: 配置多对一关系
     * .                targetEntity: 对方的实体类字节码
     * .        2.配置外键 (中间表)
     * .
     * .配置外键的过程, 配置到了多的一方, 就会在多的一方维护外键的作用
     * .
     */
    @JsonBackReference
    @ManyToOne(targetEntity = CstCustomer.class, fetch = FetchType.EAGER)
    @JoinColumn(name = "lkm_cust_id", referencedColumnName = "cust_id", insertable = false, updatable = false)
    private CstCustomer customer;
}
